﻿@model Zor_Web.Models.Browse.V_BuildingBrowse
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>楼宇浏览</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>
</head>
<body>
    <div class="layui-tab layui-tab-brief main-tab-container">
        <div class="col-sm-12 ct-padding">
            <button id="btnSearch" class="layui-btn  layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span>查询</button>
        </div>
        <div class="col-sm-12  layui-tab-content">
            <div class="mail-box" style="overflow-x:scroll;white-space:nowrap;">
                <table class="layui-table" lay-skin="line">
                    <thead>
                        <tr>
                            <th hidden></th>
                            <th>街道办</th>
                            <th>社区</th>
                            <th>楼宇名称</th>
                            <th>地上层数</th>
                            <th>地下层数</th>
                            <th>经度</th>
                            <th>纬度</th>
                            <th>管理员姓名</th>
                            <th>管理员性别</th>
                            <th>管理员身份证号</th>
                            <th>管理员电话</th>
                            <th>创建时间</th>
                        </tr>
                    </thead>
                    <tbody id="accordion">
                        @foreach (var item in Model.PageData)
                    {
                            <tr>
                                <td hidden>@item.Bd_Id</td>
                                <td>@item.StreetOffice</td>
                                <td>@item.Community</td>
                                <td>@item.Bd_Name</td>
                                <td>@item.Bd_Ground</td>
                                <td>@item.Bd_Underground</td>
                                <td>@item.Bd_Longitude</td>
                                <td>@item.Bd_Latitude</td>
                                <td>@item.Bd_Aname</td>
                                <td>@item.Bd_Sex</td>
                                <td>@item.Bd_IDNumber</td>
                                <td>@item.Bd_Telephone</td>
                                @if (@item.Bd_CreateDate != null)
                            {
                                    <td>@TimeHelper.TimeStampToDateTime(item.Bd_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            }
                            else
                            {
                                    <td>无</td>
                            }

                            </tr>
                    }
                    </tbody>
                </table>
                <div class="row">
                    <div class="col-sm-9">
                        @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "", @class = "pagination" })
                    </div>
                    <div class="col-sm-3">
                        共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
                    </div>
                </div>
            </div>
        </div>
    </div>
        <!-- 模态:查询 -->
        @using (Html.BeginForm("BuildingBrowse", "Browse", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
        {
            <div id="QueryModal" style="display: none;padding: 20px;">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">街道办：</label>
                        <div class="col-sm-9">
                            <select name="StreetOffice" class="form-control" id="StreetOffice"></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">社区：</label>
                        <div class="col-sm-9">
                            <select class="form-control" name="Community" id="Community"></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">楼宇名称：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="Bd_Name" value="@Model.Bd_Name">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">管理员姓名：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="Bd_Aname" value="@Model.Bd_Aname">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">创建时间：</label>
                        <div class="col-sm-9">
                            <input id="Bd_CreateDate" name="Bd_CreateDate" class="form-control layer-date laydate-icon" placeholder=" 创建时间" onclick="laydate({ istime: false, format: 'YYYY-MM-DD' })" value="@Model.Bd_CreateDate">
                        </div>
                    </div>
                </form>
                <div class="box-footer">
                    <button type="submit" id="btnQuery" class="btn btn-info pull-right">
                        <i class="fa fa-search"></i>查询
                    </button>
                </div>
            </div>
        }
</body>
</html>
<script>
    /**
 * 日期选择器
 */
    laydate(
    { elem: "#Bd_CreateDate", event: "focus" }
    );


    /**
     * 查询
   **/
    $(function () {
        $("#btnSearch").click(function () {
            GetCommunity();
            GetStreetOffice();
            LayerOpen('550px', '38  0px', '查询条件', $('#QueryModal'));//打开查询信息模态框          
        })
    })


    //获取当前社区名称
    function GetCommunity() {
        getAjax("/Browse/SelectCommunity", "", function (data) {
            accordionJson = eval("(" + data + ")");
            $("#Community").append("<option value='' >---     选择社区    ---</option>")
            $.each(accordionJson, function (i) {
                $("#Community").append("<option value='" + accordionJson[i].Dt_Name + "' >" + accordionJson[i].Dt_Name + "</option>");
            });
        });

    }
    //获取当前街道办
    function GetStreetOffice() {
        getAjax("/Browse/SelectStreetOffice", "", function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                $("#StreetOffice").append("<option value='" + accordionJson[i].Dt_Name + "' >" + accordionJson[i].Dt_Name + "</option>");
            });
        });
    }
</script>